#ifndef GRAPHICS_OGL_H
#define GRAPHICS_OGL_H

#include "../../src/level.h"
#include "lib3dexport.h"
#include "graphicsInterface.h"

#include <GL/glew.h>
#include <SDL/SDL.h>

#include <list>

namespace LibPhysics {
	class Physics;
}

namespace Lib3D {

class LIB3D_API Graphics : public GraphicsInterface {
public:
	Graphics(Level & level, LibPhysics::Physics & physics);
	virtual ~Graphics();

	virtual void   Draw();          
	virtual void   NextFrame();   
	virtual void   DrawPoint(float x, float y, float z);
	virtual void   DrawLine(float x1, float y1, float z1, float x2, float y2, float z2, float r, float g, float b);
private:
	int windowWidth, windowHeight;

	Level & level;
	LibPhysics::Physics & physics;
	std::list<Obstacle*> croppedObstacles;

	// Hall
	GLuint hallFragmentShader;
	GLuint hallProgram;
	GLuint hallPositionsVBO;
	GLuint hallColorsVBO;
	GLuint hallIndicesVBO;
	GLsizei hallIndicesCount;

	bool initHall();
	void drawHall();

	// Obstacles
	GLuint obstacleFragmentShader;
	GLuint obstacleProgram;

	bool initObstacle();
	void drawObstacles();

	// Player
	GLUquadricObj * playerCylinders[3];

	void initPlayer();
	void drawPlayer();

	// Interface
	void initInterface();
	void drawInterface();
	void drawLife();
	void drawGameOver();

	int lifeTexture, lifeMeterTexture;
	int gameOverTexture;

	int loadTexture(std::wstring & path, bool alpha);
};


}

#endif // GRAPHICS_OGL_H
